<template>
  <div id="app">
    <h3>todoList</h3>
    <input v-model="value"/>
    <button @click="handleSubmit">Add Item</button>
    <ul>
      <todo-item v-for="(item, index) of list" :key="index" :content="item" :index="index" @delete="handleDelete"></todo-item>
    </ul>
  </div>
</template>

<script>
import TodoItem from './components/TodoItem'
export default {
  components: {
    'todo-item': TodoItem
  },
  data () {
    return {
      value: '',
      list: []
    }
  },
  methods: {
    handleSubmit () {
      this.list.push(this.value)
      this.value = ''
    },
    handleDelete (index) {
      this.list.splice(index, 1)
    }
  }
}

</script>

<style>
#app {
  margin: 40vh auto;
  width: 300px;
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  color: #2c3e50;
}
ul{
  padding: 0;
}
</style>
